package com.fix.web;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.fix.dao.AuthDao;
import com.fix.dao.UserDao;
import com.fix.dao.impl.AuthDaoImpl;
import com.fix.dao.impl.UserDaoImpl;
import com.fix.entity.Authority;
import com.fix.entity.User;

/**
 *  得到所有用户
 */
@WebServlet("/getusers")
public class GetUsersServlet extends HttpServlet {
	
	UserDao userDao =new UserDaoImpl();
	AuthDao authDao = new AuthDaoImpl();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		List<User> userlist=null;
		List<Authority> authlist=null;
		try {
			userlist = (List)userDao.getUsers();  // 所有用户
			authlist = (List)authDao.getAuthList();  //所有权限
			
			request.setAttribute("userlist", userlist);
			request.setAttribute("authlist", authlist);
			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		request.getRequestDispatcher("/admin.jsp").forward(request, response);
		
	}

	 
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
